package com.itheima.travel.service.impl;

import com.itheima.travel.mapper.CategoryMapper;
import com.itheima.travel.pojo.Category;
import com.itheima.travel.pojo.CategoryExample;
import com.itheima.travel.req.CategoryVo;
import com.itheima.travel.service.CategoryService;
import com.itheima.travel.utils.BeanConv;
import com.itheima.travel.utils.EmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryMapper categoryMapper;

    /**
     * 查询全部分类
     * @return
     */
    @Override
    public List<CategoryVo> findAllCategory() {
        List<Category> categoryList = categoryMapper.selectByExample(new CategoryExample());
        if(!EmptyUtil.isNullOrEmpty(categoryList)){

            List<CategoryVo> categoryVoList = BeanConv.toBeanList(categoryList, CategoryVo.class);
            return categoryVoList;
        }
        return null;
    }
}
